﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace SPSIndia.XSLDemo.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {

        public VisualWebPart1 myParent;
        private string myXslFileUrl;

        protected void Page_Load(object sender, EventArgs e)
        {

            PretendAnnouncementsCollection pac;
            XslHelperClass xslUtil;

            try
            {
                // Get a reference to my XSL File Url.
                myXslFileUrl = myParent.XslUrl;
                xslUtil = new XslHelperClass();

                // Instantiate and create some pretend announcements.
                pac = new PretendAnnouncementsCollection();
                pac.GenerateTestData();

                if (myParent.DoEncodeHtmlResults)
                  this.TransformedResult.Text = 
                      Server.HtmlEncode(xslUtil.TransformXmlStringToHtml(myXslFileUrl, pac.PretendAnnouncementsAsXmlString));
                else
                    this.TransformedResult.Text = 
                        xslUtil.TransformXmlStringToHtml(myXslFileUrl, pac.PretendAnnouncementsAsXmlString);

            }
            catch (Exception e2)
            {
                ErrorMessage.Text = e2.ToString();

            }
        } // Page_Load

    } // user control
} // namespace
